CS184 Hw4 Writeup
Haoqing Xuan 3036149505
Maodun Zhang 3035626112
Part 1:
Implementation overview:
Firstly, we reserve memory for our point masses. Then, for a horizontal orientation, we go
through each row and column, figuring out where each point mass should be placed. Similarly,
for a vertical orientation, we add randomness to the z-axis. We also check if any points are
pinned by iterating through the pinned vector. Lastly, we create springs by checking the index of
the point masses and then we add the corresponding springs into the arrays.
This is the result of scene/pinned2.json, where we can clearly see the cloth wireframe and the
structure of point masses and springs.
Here is the wireframe:
Without any shearing structure
With only shearing structure
With add constraints
Part 2
When we change the ks to a lower value, we can observe that the springs seem to change from
the 4 pinned corners first and then gradually move toward the center of the sheet. And the corner
seems sharper as if there’s a string under the sheet to hold the corner up.
However, for high ks, we can observe that the surface around the corner is much smoother, and
the springs change spread faster toward the center of the sheet compared to low ks.
Below are image of having density of 100 g/cm^2, and we can see that the image with high
density has more obvious curve at the center of the sheet, as if a heavier object is placed at the
center that drags the sheet down. When we have low density, 5 g/cm^2, the influence on the
sheet is much less and the surface around the pinned corners are much smoother. Another
intersting fact is that if we decrease the density and immediately start simulation, the sheet seems
to “bounce back” since less pressure is on the surface.
Below are the images of changing damping values, with low damping values like 0.06, the center
of the sheet seems less curved compared to the image with high damping values, 0.8. However,
to human eyes, the effect of changing damping values is not as obvious as changing other
parameters. The third image is the sheet with 0.2 damping value.
Below are the pictures of scene/pinned4.json using only default parameters from different angles.
Part 3
Image of ks = 5000 N/m scene/sphere.json
Image of ks = 500 N/m scene/sphere.json
Image of ks = 50000 N/m scene/sphere.json
The difference between the three ks levels is mainly displayed in the distortion of the cloth.
When fully landed on the sphere, a higher ks level results in a lesser distortion of the cloth. This
is because the ks level determines the likelihood of material changing its shape. Higher ks means
the cloth is less likely to bend or change in shape due to forces. Thus in the sample with ks = 500
N/m, the cloth closely sticks to the sphere, revealing a larger curve; while in the sample with ks =
50000 N/m, the cloth reveals a smaller curve of the top of the sphere.
Image of scene/plane.json
In Part 3 Task 2, the cloth lies on the plane. We used Phong shading and changed the color of the
cloth to green for a better presentation.
Part 4
Image of scene/selfCollision.json - Early
Image of scene/selfCollision.json - First self-collision
Image of scene/selfCollision.json - Well folded
Image of scene/selfCollision.json - At rest
Different density values
Image of scene/selfCollision.json - 3x Default density - Well folded
Image of scene/selfCollision.json - 0.1x Default density - At rest
A cloth with a higher density would be heavier. This means it falls faster and has more
momentum, leading to less fluttering and more pronounced folds as it collapses onto itself. The
final resting position of a heavier cloth folds more to itself and stacks more tightly.
Conversely, a cloth with a lower density would be lighter. It falls more slowly and flutters or
waves more as it descends. It would react to smaller forces and might exhibit more intricate and
numerous folds since less force is required to bend or twist the material. A lighter cloth's final
resting position is smoother and looks like paper.
Part 5:
Shaders are isolated programs that run in parallel on GPU, executing sections of the graphics
pipeline, taking in an input, and outputting a single 4-dimensional vector. We know that vertex
shaders are shaders that apply transforms to vertices by modifying their geometric properties like
position and normal vectors, writing the final position of the vertex to gl_Position in addition to
writing varyings for use in the fragment shader. And the fragment shaders are what we get after
rasterization, which these shaders process. Fragment shaders generally take in geometric
attributes of the fragment calculated by the vertex shader to compute and write color into
out_color.
The Blinn-Phong shading model is a lighting model used in computer graphics to simulate how
light interacts with surfaces. It consists of three main components. Firstly, ambient Light
provides a constant color contribution to the surface, representing overall scene lighting. Diffuse
Reflection models light scattering on rough surfaces, determining the base color of objects based
on their orientation to light sources. Specular Highlights simulates shiny surfaces by calculating
bright highlights where light reflects off the surface, using a halfway vector between the light
direction and view direction. And by combining these components with material properties like
ambient, diffuse, and specular colors, the Blinn-Phong model creates realistic lighting effects in
real-time rendering applications like games and simulations.
Blinn-Phong Shader
scene/sphere.json - Ambient Lighting
scene/sphere.json - Diffuse Lighting
scene/sphere.json - Specular Lighting
scene/sphere.json - Blinn-Phong Lighting
Custom texture
Custom Texture - continued
scene/sphere.json - Custom texture
Bumping
scene/sphere.json - Bumping
Mirror
scene/sphere.json - Mirror